home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Libraries / WASTE 1.1a4 / Interfaces 2 / TextServices.p < prev   
Encoding:
Text File  |  1994-10-31  |  8.5 KB  |  300 lines  |  [TEXT/PJMM]

  1. unit TextServices;
  2.  
  3. { Pascal interface to the Macintosh Libraries: }
  4. { Text Services Manager }
  5.  
  6. { Based on material copyrighted by Apple Computer, Inc. }
  7. { ANTIĀ© 1993 Merzwaren }
  8.  
  9. { 10/31/94: commented out some definitions because of conflicts with AERegistry.p, }
  10. { which is now included in the interface section }
  11.  
  12. interface
  13.     uses
  14.         AppleEvents, AERegistry, Components;
  15.  
  16.     const
  17.  
  18.         gestaltTSMgrVersion = 'tsmv';            { Text Services Manager gestalt selector }
  19.  
  20.         kTSMVersion = 1;                                { version of Text Services Manager }
  21.         kTextService = 'tsvc';                        { component type }
  22.         kInputMethodService = 'inpm';            { component subtype }
  23.  
  24.         bTakeActiveEvent = 15;                    { bit set if component takes activate events }
  25.         bScriptMask = $00007F00;
  26.         bLanguageMask = $000000FF;
  27.         bScriptLanguageMask = bScriptMask + bLanguageMask;
  28.  
  29. { hilite styles }
  30.  
  31.         kCaretPosition = 1;                            { specify caret position }
  32.         kRawText = 2;                                    { specify range of raw text }
  33.         kSelectedRawText = 3;                        { specify range of selected raw text }
  34.         kConvertedText = 4;                            { specify range of converted text }
  35.         kSelectedConvertedText = 5;                { specify range of selected converted text }
  36.  
  37. { Apple Event constants }
  38.  
  39.         kTextServiceClass = kTextService;    { event class }
  40.         kUpdateActiveInputArea = 'updt';    { update active inline area }
  41.         kPos2Offset = 'p2st';                            { convert global coordinates to text offset }
  42.         kOffset2Pos = 'st2p';                            { convert text offset to global coordinates }
  43.         kShowHideInputWindow = 'shiw';    { show or hide the input window }
  44.  
  45. { event keywords }
  46.  
  47.         keyAETSMDocumentRefCon = 'refc';    { TSM document refcon }
  48.         keyAEServerInstance = 'srvi';            { server instance }
  49.         keyAETheData = 'kdat';                        { text }
  50.         keyAEScriptTag = 'sclg';                    { script & language tags }
  51.         keyAEFixLength = 'fixl';                    { length of confirmed text }
  52.         keyAEHiliteRange = 'hrng';                { hilite range array }
  53.         keyAEUpdateRange = 'udng';            { update range array }
  54.         keyAEClauseOffsets = 'clau';                { clause offsets array }
  55.         keyAECurrentPoint = 'cpos';                { current point }
  56.         keyAEDragging = 'bool';                    { dragging flag }
  57.         keyAEOffset = 'ofst';                            { text offset }
  58.         keyAERegionClass = 'rgnc';                { region class }
  59.         keyAEPoint = 'gpos';                            { current point }
  60.         keyAEBufferSize = 'buff';                    { buffer size to get the text }
  61. { keyAERequestedType = 'rtyp';            [ requested text type; defined in AERegistry.p ] }
  62.         keyAEMoveView = 'mvvw';                { move view flag }
  63.         keyAELength = 'leng';                        { length }
  64.         keyAENextBody = 'nxbd';                    { next or previous body }
  65.  
  66. { optional keywords for Offset2Pos }
  67.  
  68. { keyAETextFont = 'ktxf'; [ defined in AERegistry.p ] }
  69. { keyAETextPointSize = 'ktps'; [ defined in AERegistry.p ] }
  70.         keyAETextLineHeight = 'ktlh';
  71.         keyAETextLineAscent = 'ktas';
  72. { keyAEAngle = 'kang'; [ defined in AERegistry.p ] }
  73.  
  74. { optional keyword for Pos2Offset }
  75.  
  76.         keyAELeftSide = 'klef';
  77.  
  78. { optional keyword for ShowHideInputWindow }
  79.  
  80.         keyAEShowHideInputWindow = 'shiw';
  81.  
  82. { keyword for PinRange }
  83.  
  84.         keyAEPinRange = 'pnrg';
  85.  
  86. { descriptor types }
  87.  
  88.         typeComponentInstance = 'cmpi';
  89.         typeTextRange = 'txrn';
  90.         typeTextRangeArray = 'tray';
  91.         typeOffsetArray = 'ofay';
  92. { typeIntlWritingCode = 'intl'; [ defined in AERegistry.p ] }
  93. { typeQDPoint = 'QDpt'; [ defined in AERegistry.p ] }
  94. { typeAEText = 'tTXT'; [ defined in AERegistry.p ] }
  95.         typeText = 'TEXT';
  96.  
  97. { descriptor type constants }
  98.  
  99.         kTSMOutsideOfBody = 1;
  100.         kTSMInsideOfBody = 2;
  101.         kTSMInsideOfActiveInputArea = 3;
  102.  
  103.         kNextBody = 1;
  104.         kPreviousBody = 2;
  105.  
  106. { Apple Event error constants }
  107.  
  108.         errOffsetInvalid = -1800;
  109.         errOffsetIsOutsideOfView = -1801;
  110.         errTopOfDocument = -1810;
  111.         errTopOfBody = -1811;
  112.         errEndOfDocument = -1812;
  113.         errEndOfBody = -1813;
  114.  
  115. { Text Services Manager result codes }
  116.  
  117.         tsmComponentNoErr = noErr;
  118.         tsmUnsupScriptLanguageErr = -2500;
  119.         tsmInputMethodNotFoundErr = -2501;
  120.         tsmNotAnAppErr = -2502;
  121.         tsmAlreadyRegisteredErr = -2503;
  122.         tsmNeverRegisteredErr = -2504;
  123.         tsmInvalidDocIDErr = -2505;
  124.         tsmTSMDocBusyErr = -2506;
  125.         tsmDocNotActiveErr = -2507;
  126.         tsmNoOpenTSErr = -2508;
  127.         tsmCantOpenComponentErr = -2509;
  128.         tsmTextServiceNotFoundErr = -2510;
  129.         tsmDocumentOpenErr = -2511;
  130.         tsmUseInputWindowErr = -2512;
  131.         tsmTSHasNoMenuErr = -2513;
  132.         tsmTSNotOpenErr = -2514;
  133.         tsmComponentAlreadyOpenErr = -2515;
  134.         tsmInputMethodIsOldErr = -2516;
  135.         tsmScriptHasNoIMErr = -2517;
  136.         tsmUnsupportedTypeErr = -2518;
  137.         tsmUnknownErr = -2519;
  138.  
  139. { data types }
  140.  
  141.     type
  142.  
  143.         TextRange = record
  144.                 fStart: LongInt;
  145.                 fEnd: LongInt;
  146.                 fHiliteStyle: Integer;
  147.             end;
  148.         TextRangePtr = ^TextRange;
  149.         TextRangeHandle = ^TextRangePtr;
  150.  
  151.         TextRangeArray = record
  152.                 fNumOfRanges: Integer;
  153.                 fRange: array[0..0] of TextRange;
  154.             end;
  155.         TextRangeArrayPtr = ^TextRangeArray;
  156.         TextRangeArrayHandle = ^TextRangeArrayPtr;
  157.  
  158.         OffsetArray = record
  159.                 fNumOfOffsets: Integer;
  160.                 fOffset: array[0..0] of LongInt;
  161.             end;
  162.         OffsetArrayPtr = ^OffsetArray;
  163.         OffsetArrayHandle = ^OffsetArrayPtr;
  164.  
  165.         TextServiceInfo = record
  166.                 fComponent: Component;
  167.                 fItemName: Str255;
  168.             end;
  169.         TextServiceInfoPtr = ^TextServiceInfo;
  170.  
  171.         TextServiceList = record
  172.                 fTextServiceCount: Integer;
  173.                 fServices: array[0..0] of TextServiceInfo;
  174.             end;
  175.         TextServiceListPtr = ^TextServiceList;
  176.         TextServiceListHandle = ^TextServiceListPtr;
  177.  
  178.         ScriptLanguageRecord = record
  179.                 fScript: ScriptCode;
  180.                 fLanguage: LangCode;
  181.             end;
  182.  
  183.         ScriptLanguageSupport = record
  184.                 fScriptLanguageCount: Integer;
  185.                 fScriptLanguageArray: array[0..0] of ScriptLanguageRecord;
  186.             end;
  187.         ScriptLanguageSupportPtr = ^ScriptLanguageSupport;
  188.         ScriptLanguageSupportHandle = ^ScriptLanguageSupportPtr;
  189.  
  190.         InterfaceTypeList = array[0..0] of OSType;
  191.  
  192.         TSMDocumentID = Ptr;
  193.  
  194. { Text Services Manager Routines for Client Applications }
  195.  
  196.     function InitTSMAwareApplication: OSErr;
  197.     inline
  198.         $7014, $AA54;
  199.     function CloseTSMAwareApplication: OSErr;
  200.     inline
  201.         $7015, $AA54;
  202.     function NewTSMDocument (numOfInterface: Integer;
  203.                                     var supportedInterfaceTypes: InterfaceTypeList;
  204.                                     var idocID: TSMDocumentID;
  205.                                     refCon: LongInt): OSErr;
  206.     inline
  207.         $7000, $AA54;
  208.     function DeleteTSMDocument (idocID: TSMDocumentID): OSErr;
  209.     inline
  210.         $7001, $AA54;
  211.     function ActivateTSMDocument (idocID: TSMDocumentID): OSErr;
  212.     inline
  213.         $7002, $AA54;
  214.     function DeactivateTSMDocument (idocID: TSMDocumentID): OSErr;
  215.     inline
  216.         $7003, $AA54;
  217.     function TSMEvent (var event: EventRecord): Boolean;
  218.     inline
  219.         $7004, $AA54;
  220.     function TSMMenuSelect (menuResult: LongInt): Boolean;
  221.     inline
  222.         $7005, $AA54;
  223.     function SetTSMCursor (mousePos: Point): Boolean;
  224.     inline
  225.         $7006, $AA54;
  226.     function FixTSMDocument (idocID: TSMDocumentID): OSErr;
  227.     inline
  228.         $7007, $AA54;
  229.     function GetServiceList (numOfInterfaceTypes: Integer;
  230.                                     var supportedInterfaceTypes: InterfaceTypeList;
  231.                                     var serviceInfo: TextServiceListHandle;
  232.                                     var seedValue: LongInt): OSErr;
  233.     inline
  234.         $7008, $AA54;
  235.     function OpenTextService (idocID: TSMDocumentID;
  236.                                     aComponent: Component;
  237.                                     var aComponentInstance: ComponentInstance): OSErr;
  238.     inline
  239.         $7009, $AA54;
  240.     function CloseTextService (idocID: TSMDocumentID;
  241.                                     aComponentInstance: ComponentInstance): OSErr;
  242.     inline
  243.         $700A, $AA54;
  244.     function UseInputWindow (idocID: TSMDocumentID;
  245.                                     useWindow: Boolean): OSErr;
  246.     inline
  247.         $7010, $AA54;
  248.  
  249. { Utilities -- called by the Script Manager }
  250.  
  251.     function SetDefaultInputMethod (ts: Component;
  252.                                     var slRecord: ScriptLanguageRecord): OSErr;
  253.     inline
  254.         $700C, $AA54;
  255.     function GetDefaultInputMethod (var ts: Component;
  256.                                     var slRecord: ScriptLanguageRecord): OSErr;
  257.     inline
  258.         $700D, $AA54;
  259.     function SetTextServiceLanguage (var slRecord: ScriptLanguageRecord): OSErr;
  260.     inline
  261.         $700E, $AA54;
  262.     function GetTextServiceLanguage (var slRecord: ScriptLanguageRecord): OSErr;
  263.     inline
  264.         $700F, $AA54;
  265.  
  266. { Text Services Manager Routines for Components }
  267.  
  268.     function SendAEFromTSMComponent (var theAppleEvent: AppleEvent;
  269.                                     var reply: AppleEvent;
  270.                                     sendMode: AESendMode;
  271.                                     sendPriority: AESendPriority;
  272.                                     timeOutInTicks: LongInt;
  273.                                     idleProc: IdleProcPtr;
  274.                                     filterProc: EventFilterProcPtr): OSErr;
  275.     inline
  276.         $700B, $AA54;
  277.     function NewServiceWindow (wStorage: Ptr;
  278.                                     boundsRect: Rect;
  279.                                     title: Str255;
  280.                                     visible: Boolean;
  281.                                     theProc: Integer;
  282.                                     behind: WindowPtr;
  283.                                     goAwayFlag: Boolean;
  284.                                     ts: ComponentInstance;
  285.                                     var window: WindowPtr): OSErr;
  286.     inline
  287.         $7011, $AA54;
  288.     function CloseServiceWindow (window: WindowPtr): OSErr;
  289.     inline
  290.         $7012, $AA54;
  291.     function GetFrontServiceWindow (var window: WindowPtr): OSErr;
  292.     inline
  293.         $7013, $AA54;
  294.     function FindServiceWindow (thePoint: Point;
  295.                                     var theWindow: WindowPtr): Integer;
  296.     inline
  297.         $7017, $AA54;
  298.  
  299. implementation
  300. end.